From: Jasper St. Pierre Date: Wed, 2 May 2012 19:26:54 +0000 (-0400) Subject: search: Allow synchronous searches to be defined with the async API X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~1013^2^2~6611 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=0bf6c93faa724afc2b972107f240d4976faa9e7f;p=gnome-shell.git search: Allow synchronous searches to be defined with the async API To allow this to happen, we need to make sure that we don't overwrite the previousResults when calling the async method. Note that this is a bug of some sort, we were already using this synchronous style when a remote search failed. https://bugzilla.gnome.org/show_bug.cgi?id=675328 --- diff --git a/js/ui/search.js b/js/ui/search.js index 1d654fb81..b2348d5d2 100644 --- a/js/ui/search.js +++ b/js/ui/search.js @@ -379,14 +379,19 @@ const SearchSystem = new Lang.Class({ } } + let previousResultsArr = this._previousResults; + let results = []; + this._previousTerms = terms; + this._previousResults = results; + if (isSubSearch) { for (let i = 0; i < this._providers.length; i++) { - let [provider, previousResults] = this._previousResults[i]; + let [provider, previousResults] = previousResultsArr[i]; try { if (provider.async) { - provider.getSubsearchResultSetAsync(previousResults, terms); results.push([provider, []]); + provider.getSubsearchResultSetAsync(previousResults, terms); } else { let providerResults = provider.getSubsearchResultSet(previousResults, terms); results.push([provider, providerResults]); @@ -400,8 +405,8 @@ const SearchSystem = new Lang.Class({ let provider = this._providers[i]; try { if (provider.async) { - provider.getInitialResultSetAsync(terms); results.push([provider, []]); + provider.getInitialResultSetAsync(terms); } else { let providerResults = provider.getInitialResultSet(terms); results.push([provider, providerResults]); @@ -412,8 +417,6 @@ const SearchSystem = new Lang.Class({ } } - this._previousTerms = terms; - this._previousResults = results; this.emit('search-completed', results); }, });